<?php include '../template/template_main.tpl'; 
require("../connect/connect.php");
require ("../admin/insertProb.php");
require ("../equipa/insereRespostas.php");

if(!isset($_SESSION["profile"]))
header("Location: ../publico/comoFazerLogin.php");
if ($_SESSION["profile"] == 2)
header("Location: ../admin/adminDock.php");

$prob = getProbSemana($conn);
$probID = $prob["id"];
	
$resposta=getResposta($conn);


if(isset($_POST["submit"])){
	$error = array();
	if($_POST["resposta"] == "")
		$error[] = "Deve preencher a resposta.";
	if (count($error) == 0)
		updateResposta($conn,$resposta["id"]);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="../css/template.css" />
<link rel="stylesheet" type="text/css" href="../css/corpo_main.css" />
<script type="text/javascript" src="../js/jquery-1.7.2.js" ></script>
<script type="text/javascript" src="../js/main.js" ></script>

<title>.:MateMatrix:.</title>

</head>
<body>
	<?php makeHeader(); ?>
	<?php echo $estruturaInicio;?>
	<h2>Título:</h2>
	<pre>
<?php echo $prob["titulo"];?>
	</pre>
	<h2>Problema:</h2>
	<pre>
<?php echo $prob["problema"];?>
	</pre>
	<form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
		<div>
			<div>
				<label>Resposta:</label>
			</div>
			<div class="texto">
				<textarea rows="10" cols="1" name="resposta"><?php if (isset($resposta)) echo $resposta["resposta"];?></textarea> 
			</div>
		</div>
		<div>
			<div>
				<input type="submit" name="submit" value="Modificar"/> 
			</div>
		</div>
	</form>
	<?php echo $estruturaFim; ?>
	<?php echo $footer;?>
</body>
</html>